]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Slide out removed workspaces in linear view
authorFlorian Müllner <fmuellner@src.gnome.org>
Thu, 11 Feb 2010 14:52:49 +0000 (15:52 +0100)
committerFlorian Müllner <fmuellner@src.gnome.org>
Wed, 17 Feb 2010 22:37:05 +0000 (23:37 +0100)
Instead of deleting workspaces immediately, animate the removal - it may
be useless eye-candy, but it's pretty sexy nonetheless ...
More seriously, the animation improves consistency with both workspace
additions and the mosaic view.

https://bugzilla.gnome.org/show_bug.cgi?id=609673

js/ui/workspacesView.js

index 8a36ba5da20b0ec23487035ef0ace742e53fc50e..0cdca95f6d3d88c6ce260bd504a749229d3aa0bd 100644 (file)
@@ -466,6 +466,7 @@ SingleView.prototype = {
         this._indicatorsPanel = null;
         this._indicatorsPanelWidth = null;
         this._scroll = null;
+        this._lostWorkspaces = [];
         this._scrolling = false;
         this._animatingScroll = false;
     },
@@ -539,6 +540,37 @@ SingleView.prototype = {
                     workspace.actor.hide();
             }
         }
+
+        for (let l = 0; l < this._lostWorkspaces.length; l++) {
+            let workspace = this._lostWorkspaces[l];
+
+            workspace.gridX += dx;
+            workspace.actor.show();
+            workspace._hideAllOverlays();
+
+            if (showAnimation) {
+                Tweener.addTween(workspace.actor,
+                    { x: workspace.gridX,
+                      time: WORKSPACE_SWITCH_TIME,
+                      transition: 'easeOutQuad',
+                      onComplete: Lang.bind(this, this._cleanWorkspaces)
+                    });
+            } else {
+                this._cleanWorkspaces();
+            }
+        }
+    },
+
+    _cleanWorkspaces: function() {
+        if (this._lostWorkspaces.length == 0)
+            return;
+
+        for (let l = 0; l < this._lostWorkspaces.length; l++)
+            this._lostWorkspaces[l].destroy();
+        this._lostWorkspaces = [];
+
+        this._positionWorkspaces();
+        this._updateWorkspaceActors();
     },
 
     _scrollScrollBarToIndex: function(index, showAnimation) {
@@ -583,18 +615,27 @@ SingleView.prototype = {
             this._scrollScrollBarToIndex(active + 1, false);
 
         } else {
-            for (let i = 0; i < this._workspaces.length; i++)
-                this._workspaces[i].destroy();
-            this._workspaces = [];
-            this._actor.remove_all();
-
-            // Without this there will be lots of warnings
-            this._actor.hide();
-            for (let w = 0; w < global.screen.n_workspaces; w++)
-                this._addWorkspaceActor(w);
-            this._actor.show();
-            this._positionWorkspaces();
-            this._updateWorkspaceActors();
+            let active = global.screen.get_active_workspace_index();
+            let removedNum = oldNumWorkspaces - newNumWorkspaces;
+            let removedIndex = active + 1;
+            this._lostWorkspaces = this._workspaces.splice(removedIndex,
+                                                           removedNum);
+
+            // Don't let the user try to select this workspace as it's
+            // making its exit.
+            for (let l = 0; l < this._lostWorkspaces.length; l++)
+                this._lostWorkspaces[l]._desktop.actor.reactive = false;
+
+            // reassign workspaceNum and metaWorkspace, as lost workspaces
+            // have not necessarily been removed from the end
+            for (let i = removedIndex; i < this._workspaces.length; i++) {
+                let metaWorkspace = global.screen.get_workspace_by_index(i);
+                this._workspaces[i].workspaceNum = i;
+                this._workspaces[i]._metaWorkspace = metaWorkspace;
+            }
+
+            this._scrollScrollBarToIndex(active, false);
+            this._scrollToActive(true);
         }
 
         this._updatePanelVisibility();